/*
 * @Author: liuzibin
 * @Date: 2023-07-24 23:49:21
 * @Descroption: 添加订单评价
 */

const axios = require("axios");

async function addComment({ orderId, userToken }) {
  const response = await axios.post(
    `https://borderclear.cn/api/reply/${orderId}`,
    {
      comment: generateProductReview(),
      pics: [],
      product_score: 5,
      service_score: 5,
      postage_score: 5,
    },
    {
      headers: {
        Accept: "application/json, text/plain, */*",
        Referer: "http://borderclear.cn/admin/merchant/list",
        "X-Token": userToken,
        "User-Agent":
          "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
        "Content-Type": "application/json;charset=UTF-8",
      },
    }
  );
  console.log(response.data);
  return true;
}

// List of positive adjectives
const positiveAdjectives = [
  "excellent",
  "great",
  "amazing",
  "impressive",
  "wonderful",
  "fantastic",
  "awesome",
  "terrific",
  "outstanding",
  "superb",
];

// List of positive nouns
const positiveNouns = [
  "product",
  "purchase",
  "item",
  "choice",
  "buy",
  "selection",
  "option",
  "investment",
  "acquisition",
  "deal",
];

// Generate a random product review
function generateProductReview() {
  // Randomly select a positive adjective and noun
  const randomAdjective =
    positiveAdjectives[Math.floor(Math.random() * positiveAdjectives.length)];
  const randomNoun =
    positiveNouns[Math.floor(Math.random() * positiveNouns.length)];

  // Construct the review content
  const review = `This ${randomAdjective} ${randomNoun} is absolutely incredible!`;

  return review;
}

module.exports = addComment;
